package com.jz.community.moduleshoppingguide.home.ui.adapter;

import android.support.annotation.Nullable;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jz.community.moduleshoppingguide.R;
import com.jz.community.moduleshoppingguide.home.bean.CategoriesBean;

import java.util.List;


/**
 * Created by Ani_H on 2018/3/6.
 */

public class HomeTabAdapter extends BaseQuickAdapter<CategoriesBean, BaseViewHolder> {

    public HomeTabAdapter(int layoutResId, @Nullable List<CategoriesBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, CategoriesBean entity) {
        boolean isSelect = entity.isSelect();
        TextView pop_tv = helper.getView(R.id.item_pop_home_tv);
        pop_tv.setText(entity.getName());
        if (isSelect) {
            pop_tv.setBackgroundResource(R.drawable.border_loc_red_line);
        } else {
            pop_tv.setBackgroundResource(R.drawable.border_loc_gray_line);
        }
    }


    public void setChick(int pos) {
        for (int i = 0; i < mData.size(); i++) {
            mData.get(i).setSelect(false);
        }
        mData.get(pos).setSelect(true);
        notifyDataSetChanged();
    }
}
